#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>
#include <QImage>
#include <QPixmap>
#include <QDateTime>
#include <QDir>
#include <QVector>
#include <QTimer>
#include <QtConcurrent>
#include <QEventLoop>
// 引入海康威视 SDK 的头文件
#include "HCNetSDK.h"
#include "LinuxPlayM4.h"

#include <opencv2/opencv.hpp>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;

    LONG lRealPlayHandle;
    LONG lUserID;
    LONG g_nPort;
    cv::Mat g_BGRImage;

    static void CALLBACK g_RealDataCallBack_V30(LONG lPlayHandle, DWORD dwDataType, BYTE* pBuffer, DWORD dwBufSize, void* pUser);
    static void CALLBACK DecCBFun(int nPort, char* pBuf, int nSize, FRAME_INFO* pFrameInfo, void* nUser, int nReserved2);
    void getPort();

    void onNewImageReady(const cv::Mat& mat);
    void on_pushButton_login_clicked();
    void on_pushButton_realplay_clicked(bool toggled_flag);
    void on_pushButton_left_clicked(bool toggled_flag);
    void on_pushButton_right_clicked(bool toggled_flag);
    void on_pushButton_up_clicked(bool toggled_flag);
    void on_pushButton_down_clicked(bool toggled_flag);
    void on_pushButton_left_up_clicked(bool toggled_flag);
    void on_pushButton_right_up_clicked(bool toggled_flag);
    void on_pushButton_left_down_clicked(bool toggled_flag);
    void on_pushButton_right_down_clicked(bool toggled_flag);
    void on_pushButton_narrowfocus_clicked(bool toggled_flag);
    void on_pushButton_expandfocus_clicked(bool toggled_flag);
    void on_pushButton_nearfocus_clicked(bool toggled_flag);
    void on_pushButton_farfocus_clicked(bool toggled_flag);
    void on_pushButton_smallaperture_clicked(bool toggled_flag);
    void on_pushButton_largeaperture_clicked(bool toggled_flag);
    void on_pushButton_scrashPic_clicked();
    void on_pushButton_record_clicked(bool toggled_flag);
    void on_pushButton_getDVRConfig_clicked();
    void on_pushButton_setDVRConfig_clicked();
    void on_comboBox_ptzspeed_currentIndexChanged(int index);
    void on_comboBox_day_or_night_currentTextChanged(const QString &text);

    void ptzControlRealPlay(int command,int flag);
    int HexToDecMa(int wHex);
    int DEC2HEX_doc(int x);

    void loop_getDVRConfig();
    void delay_MSec(unsigned int msec);

signals:
    void newImageReady(const cv::Mat& mat);
    
public slots:
};
#endif // MAINWINDOW_H
